﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#pragma once

#include "GcmpDbCommonEdit.h"
#include "IObject.h"

namespace gcmp
{
    class IDocument;
    class IElement;

    /// \brief 对象打断行为
    ///
    /// 用户应该定制该打断行为，打断时框架将自动调用该行为的方法实现打断以及打断后的对象关系重建
    class GCMP_DB_COMMON_EDIT_EXPORT IElementBreakBehavior : public IObject
    {
    public:
        /// \brief 打断具体Element
        /// \param pDocument 当前文档
        /// \param pBreakElement 被打断的对象
        /// \param pNewElement 打断后新生成的对象
        /// \param breakPointToStartPointRatio 打断点到起点的距离与总长度的比例,不可为负
        /// \param isBreakElementRetainOldElementId 被打断的对象是否保留原来的ElementId
        /// \return void
        virtual void BreakConcreteElement(
            const IDocument * pDocument,
            IElement * pBreakElement,
            IElement * pNewElement,
            double breakPointToStartPointRatio,
            bool isBreakElementRetainOldElementId
        ) = 0;

        /// \brief 打断后重新建立对象关系，如连接、扣减、打洞关系
        /// \param pDocument 当前文档
        /// \param pBreakElement 被打断的对象
        /// \param pNewElement 打断后新生成的对象
        /// \return void
        virtual void RebuildElementRelationship(
            IDocument * pDocument,
            IElement * pBreakElement,
            IElement * pNewElement
        ) = 0;

        /// \brief 析构函数
        virtual ~IElementBreakBehavior() {}
    };
}
